//
//  VKJiFenShopDHController.m
//  V-Learn
//
//  Created by liubo on 2019/1/9.
//  Copyright © 2019 yxk. All rights reserved.
//

#import "VKJiFenShopDHController.h"
#import "VKJiFenShopDHChildController.h"
@interface VKJiFenShopDHController ()<ZJScrollPageViewDelegate>
@property(strong, nonatomic)NSMutableArray<NSString *> *titles;
@property(strong, nonatomic)NSMutableArray<NSString *> *ids;

@property(strong, nonatomic)NSArray<UIViewController *> *childVcs;
@property (nonatomic, strong) ZJScrollPageView *scrollPageView;

@end

@implementation VKJiFenShopDHController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"兑换记录";
    self.view.backgroundColor = [UIColor whiteColor];
//    [self.view addSubview:self.jiFenShopCollectionView];
//    [self setupDataArray];
    
    self.edgesForExtendedLayout = @[];
    self.automaticallyAdjustsScrollViewInsets = NO;
    [self setupScrollView];
}
- (void)setupScrollView{
    ZJSegmentStyle *style = [[ZJSegmentStyle alloc] init];
    //显示滚动条
    style.showLine = YES;
    style.scrollLineColor = [UIColor cz_colorWithRed:253 green:79 blue:83];
    style.scrollLineHeight = 1.5;
    style.scaleTitle = NO;
    //    style.scrollTitle = NO;
    style.autoAdjustTitlesWidth = YES;
    style.titleFont = [UIFont systemFontOfSize:16];
    style.normalTitleColor = [UIColor cz_colorWithRed:103 green:103 blue:103];
    style.selectedTitleColor = [UIColor cz_colorWithRed:40 green:40 blue:40];
    style.titleMargin = 30;
    // 颜色渐变
    style.gradualChangeTitleColor = YES;
    _titles = @[@"待兑换",@"已兑换"].mutableCopy;
    // 初始化
    self.scrollPageView = [[ZJScrollPageView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, [UIScreen cz_screenHeight] - LBNAVBAR_HEIGHT) segmentStyle:style titles:self.titles parentViewController:self delegate:self];
    [self.view addSubview:self.scrollPageView];
}

//  以下
- (NSInteger)numberOfChildViewControllers {
    return self.titles.count;
}

- (UIViewController<ZJScrollPageViewChildVcDelegate> *)childViewController:(UIViewController<ZJScrollPageViewChildVcDelegate> *)reuseViewController forIndex:(NSInteger)index {
    UIViewController<ZJScrollPageViewChildVcDelegate> *childVc = reuseViewController;
    
    if (!childVc) {
        childVc = [[VKJiFenShopDHChildController alloc] initWithID:[NSString stringWithFormat:@"%ld",index + 1]];
    }
    
//    NSLog(@"%ld-----%@",(long)index, childVc);
    
    return childVc;
}


- (BOOL)shouldAutomaticallyForwardAppearanceMethods {
    return NO;
}


@end
